// Start Inverting Opamp Tutor
// Preload Images
var inc_0 = new Image();
inc_0.src = "pngs/inc-off.png";
var inc_1 = new Image();
inc_1.src = "pngs/inc-on.png";
var dec_0 = new Image();
dec_0.src = "pngs/dec-off.png";
var dec_1 = new Image();
dec_1.src = "pngs/dec-on.png";
// set values
var volt_i = 0;
var volt_o = 0;
var volt_o2 = 0;
var vin_dsp = 0;
// Make Buttons Work
//
var inc_dec =0;
//
function fup_mv(){
document.images.incled.src = inc_1.src ;
inc_dec =1;
start_timer();
}
//
function fdn_mv(){
document.images.decled.src = dec_1.src ;
inc_dec =0;
start_timer();
}
//
function dsp_all(){
vin_dsp = volt_i/10;
volt_o = vin_dsp;
volt_o = Math.round(volt_o*100)/100;
volt_o2 = -1*volt_o
linktext[5]=  vin_dsp;
show_text(5,'dvm2');
linktext[6]=  volt_o2;
show_text(6,'dvm1');
linktext[4]= volt_o;
show_text(4,'dvm3');
}
// Timer
var tmr_1;
var tmr_2;
var t1_tm = 400;
var ramp_1 =1;
//
function start_timer(){
ramp_1 =1;
t1_tm = 400;
tmr_1=setTimeout("ud_cnt();",t1_tm);
}
//
function ud_cnt(){
if (inc_dec==1 && volt_i<1999){volt_i++;}
if (inc_dec==0 && volt_i>-1999){volt_i--;}
ramp_1++;
dsp_all();
if (ramp_1 >5){t1_tm=90;}
if (ramp_1 >50){t1_tm=9;}
if (ramp_1 >100){t1_tm=1;}
tmr_2=setTimeout("cnt_ud();",t1_tm);
}
//
function cnt_ud(){
tmr_1=setTimeout("ud_cnt();",t1_tm);
}
//
function stop_timer(){
clearTimeout(tmr_1);
clearTimeout(tmr_2);
document.images.incled.src = inc_0.src ;
document.images.decled.src = dec_0.src ;
}
//
// Online Help Start
//adapted from Link Description script- www.dynamicdrive.com
var linktext=new Array()
linktext[0]= "";
linktext[1]= "";
linktext[2]= "";
linktext[3]= "";
linktext[4]= "";
linktext[5]= "";
linktext[6]= "";
//
var ns6=document.getElementById&&!document.all
var ie=document.all

function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}

function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=' '
else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}
//  Online Help End
// End Inverting Opamp Tutor